/*
 * @Author: QinJiu
 * @Date: 2022-07-20 14:22:44
 * @LastEditors: Qinjiu
 * @LastEditTime: 2022-07-20 14:59:25
 * @Description: 有权限控制的路由 ---> 需要登录
 */
import Layout from "@/layout";

const asyncRoutes = [
  {
    path: "/menu1",
    redirect: "/menu1",
    component: Layout,
    children: [
      {
        path: "index",
        name: "Menu1",
        component: () => import("@/views/Menu1/index.vue"),
        meta: { title: "Menu1", icon: "icon-shenghuo", affix: true },
      },
    ],
  },
  {
    path: "/menu2",
    redirect: "/menu2/menu2-1",
    component: Layout,
    meta: { title: "Menu2", icon: "icon-shenghuojiaofei" },
    children: [
      {
        path: "menu2-1",
        name: "Menu2-1",
        meta: { title: "Menu2-1", icon: "icon-huiyuan" },
        component: () => import("@/views/Menu2/Menu2-1.vue"),
      },
      {
        path: "menu2-2",
        name: "Menu2-2",
        meta: { title: "Menu2-2", icon: "icon-yingshi" },
        component: () => import("@/layout/components/RouterView"),
        alwaysShow: true, // 子路由只有一个时，也显示该菜单
        redirect: "noRedirect", // 面包屑不可点击
        children: [
          {
            path: "menu2-2-1",
            name: "Menu2-2-1",
            meta: { title: "Menu2-2-1", icon: "icon-kafei" },
            component: () => import("@/views/Menu2/Menu2-2/Menu2-2-1.vue"),
          },
        ],
      },
      {
        path: "menu2-3",
        name: "Menu2-3",
        meta: { title: "Menu2-3", icon: "icon-jiudian" },
        component: () => import("@/views/Menu2/Menu2-3.vue"),
      },
    ],
  },
  {
    path: "/",
    redirect: "/home",
    component: Layout,
    children: [
      {
        path: "home",
        name: "Home",
        alias: "/", // 别名
        component: () => import("@/views/home-view/index.vue"),
        meta: { title: "主页", icon: "icon-meishi" },
      },
    ],
  },
  {
    path: "/echarts",
    component: Layout,
    alwaysShow: true, // 该菜单一直显示
    meta: { title: "图表", icon: "icon-kabao" },
    redirect: "noRedirect",
    children: [
      {
        path: "index",
        component: () => import("@/views/EchartsDemo/index.vue"),
        meta: { title: "子图表", icon: "icon-youhuiquan" },
      },
    ],
  },
  {
    path: "/error",
    component: Layout,
    redirect: "noRedirect", // 面包屑中不可被点击
    meta: {
      title: "错误页面",
      icon: "icon-zuzhi",
    },
    children: [
      {
        path: "401",
        meta: { title: "401" },
        component: () => import("@/views/error-page/401"),
      },
      {
        path: "404",
        meta: { title: "404" },
        component: () => import("@/views/error-page/404"),
      },
    ],
  },
  {
    path: "/about",
    component: Layout,
    children: [
      {
        path: "index",
        component: () =>
          import(
            /* webpackChunkName: "about" */ "@/views/about-view/index.vue"
          ),
        meta: { title: "关于", icon: "icon-huochepiao" },
      },
    ],
  },
  { path: "*", redirect: "/404", hidden: true },
];

export default asyncRoutes;
